<?php
print_r($this->data);
?>
<div class="page-header">
    <h1>
        Fasilitas
        <small>
            <i class="icon-double-angle-right"></i>
            Pembayaran Telepon, Speedy, Flexi, PLN
        </small>
    </h1>
</div>

<?php
if ($this->msg) {
    ?>
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>

        <strong>
            <i class="icon-remove"></i>
            Error
        </strong>

        <?php echo $this->msg; ?>
        <br />
    </div>
    <?php
}
    ?>

    <div class="row">
        <div class="col-xs-11">
            <form id="formPay" class="form-horizontal" role="form" action="" method="post">
                
                <!-- fromAcc input-->
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">Dari Rekening</label>
                        <div class="col-sm-9">
                        <select id="fromAcc" name="fromAcc" class="col-xs-10 col-sm-5">
                            <?php

                          foreach ($this->accountList as $oAcc) {
                                    echo "<option value='".$oAcc['bank_acc_no']."'>". $oAcc['bank_acc_num'] ."</option>";
                           }
                           ?>
                        </select>
                        </div>

                </div>
                
                
                <!-- pay_for input-->
                <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">Untuk Pembayaran</label>
                        <div class="col-sm-9">
                        <select id="pay_for" name="pay_for" class="col-xs-10 col-sm-5" required>
                            <option value=''>== Pilih Pembayaran ==</option>
                            <option value='TEL'>Telepon</option>
                            <option value='SPEEDY'>Speedy</option>
                            <option value='FLEXI'>Flexi</option>
                            <option value='PLN'>PLN</option>
                        </select>
                        </div>

                </div>

                <!-- from_list input-->
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right"><input type="radio" id="fromRadio" name="fromRadio" value="1" onclick="pilihRek(this)"/> Dari Daftar Pribadi</label>
                        <div class="col-sm-9">
                        <select id="from_list" name="from_list" class="col-xs-10 col-sm-5" disabled required>
                           <option value=''>== Pilih Daftar Pribadi ==</option>
                            <?php
                           //foreach ($this->accPersonalList as $oAcc) {
                             //       echo "<option value='".$oAcc['phone_num']."'>". $oAcc['phone_num'] ."</option>";
                           //}
                           ?>
                        </select>
                        </div>

                </div>



                <!-- no_phonecell input-->
                <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right"><input type="radio" id="fromRadio" name="fromRadio" value="2" onclick="pilihRek(this)"/> Isi Nomor Telepon/Seluler/PLN</label>
                        <div class="col-sm-9">
                        <input id="no_phonecell" name="no_phonecell" type="text" placeholder="Nomor Telepon/Seluler/PLN"
                        class="col-xs-10 col-sm-5" disabled required>
                        <br/><br/>
                        <p class="help-block">Pastikan No. Telepon/Seluler/PLN yang Anda masukan benar. Transaksi yang telah dikirim tidak dapat dibatalkan.</p>
                        </div>
                </div>


                <!-- saveAs input-->
                <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right"><input type="checkbox" id="cbSave" name="cbSave" disabled onchange="klikSave(this)"/> Simpan dalam daftar pribadi</label>
                        <div class="col-sm-9">
                        <input id="saveAs" name="saveAs" type="text" placeholder="Simpan Sebagai"
                        class="col-xs-10 col-sm-5" disabled required>
                        </div>
                </div>

                <!-- remark input-->
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">Catatan</label>
                    <div class="col-sm-9">
                        <textarea id="remark" name="remark" type="text" placeholder="Catatan"
                        class="col-xs-10 col-sm-5"></textarea>

                       
                    </div>
                </div>

            <div class="clearfix form-actions">
                <div class="col-md-offset-3 col-md-9">
                    <button class="btn btn-info" type="submit">
                        <i class="icon-ok bigger-110"></i>
                        Submit
                    </button>

                    &nbsp; &nbsp; &nbsp;
                    <button class="btn" type="reset">
                        <i class="icon-undo bigger-110"></i>
                        Reset
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>


 <script>

    $("select#pay_for").change(function(){
         var pf = $("#pay_for").val();
         var options = '';
         options += '<option value="">== Loading Daftar Pribadi ==</option>';
         $("select#from_list").html(options);
         //$("select#from_list").attr('disabled','disabled');

         $.getJSON("<?php echo $this->url() ?>/jsondata/daftarpribadi",{pay_for: pf, ajax: 'true'}, function(j){
              options = '';
              options += '<option value="">== Pilih Daftar Pribadi ==</option>';
              for (var i = 0; i < j.length; i++) {
                options += '<option value="' + j[i].phone_num + '">' + j[i].phone_num +' - '+ j[i].trans_name + '</option>';
              }
              //$("select#from_list").removeAttr('disabled');
              $("select#from_list").html(options);
        })
      });


    function pilihRek(obj){

        if (obj.value == "1"){
            $("#from_list").removeAttr('disabled');

            $("#no_phonecell").val('');
            $("#no_phonecell").attr('disabled','disabled');


            $("#cbSave").removeAttr('checked');
            $("#cbSave").attr('disabled','disabled');

        }else{

            $("#from_list").attr('disabled','disabled');

            $("#no_phonecell").removeAttr('disabled');
            $("#cbSave").removeAttr('disabled');

        }
    }

    function klikSave(obj){
        if(obj.checked){
            $("#saveAs").removeAttr('disabled');
        }else{
            $("#saveAs").val('');
            $("#saveAs").attr('disabled','disabled');
        }
    }

    function validateNumber(evt) {

        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
        return true;
      }




    </script>